package org.snail.proxy.server.netty;

import io.netty.channel.socket.SocketChannel;
import org.snail.proxy.server.config.ProxyNettyConfig;
import org.snail.proxy.server.config.ServerConfig;
import org.snail.proxy.server.netty.serialization.ProtoDecoder;
import org.snail.proxy.server.netty.serialization.ProtoEncoder;
import org.springframework.stereotype.Component;

@Component
public class ProxyClientServer extends NettyServer {
    private final ServerConfig serverConfig;

    public ProxyClientServer(ProxyNettyConfig config, ServerConfig serverConfig) {
        super(config);
        this.serverConfig = serverConfig;
    }

    @Override
    protected void initChannel(SocketChannel sh) {
        sh.pipeline().addLast(new PackageSpliter())
                .addLast(new ProtoDecoder(8192))
                .addLast(new ProtoEncoder(8192))
                .addLast(new ProxyClientHandler(serverConfig));
    }

    @Override
    public void onSendMessage(String id) {

    }
}
